import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

const routes = [
  {
    path: "",
    redirect: "/home"
  },
  {
    path: "/home",
    component: () => import("../views/home/Home")
  },
  {
    path: "/category",
    component: () => import("../views/category/Category")
  },
  {
    path: "/cart",
    component: () => import("../views/cart/Cart")
  },
  {
    path: "/profile",
    component: () => import("../views/profile/Profile")
  }
];

// routes.forEach(route => {
//   route.path = route.path || "/" + (route.name || "");
// });

const router = new Router({
  routes: routes,
  mode: "history"
});

// router.beforeEach((to, from, next) => {
//   const title = to.meta && to.meta.title;
//   if (title) {
//     document.title = title;
//   }
//   next();
// });

export default router;
